#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 2e5 + 10;

int n,a[N],id[N],ans[N];

struct node { int lmx,rmx,s; } val[N << 2];
node operator + (node a,node b) { return (node) { max(a.lmx,a.s + b.lmx),max(b.rmx,b.s + a.rmx),a.s + b.s }; }

void build(int o = 1,int l = 1,int r = n) {
	if(l == r) return val[o] = (node) { 1 , 1 , 1 } , void(); int mid = l + r >> 1;
	build(o << 1,l,mid); build(o << 1 | 1,mid + 1,r); val[o] = val[o << 1] + val[o << 1 | 1];
}

void upd(int pos,int v,int o = 1,int l = 1,int r = n) {
	if(l == r) return val[o] = (node) { max(v,0),max(v,0),v } , void(); int mid = l + r >> 1;
	if(pos <= mid) upd(pos,v,o << 1,l,mid); else upd(pos,v,o << 1 | 1,mid+1,r); val[o] = val[o << 1] + val[o << 1 | 1];
}

node query(int xl,int xr,int o = 1,int l = 1,int r = n) {
	if(xl > xr) return (node){ 0,0,0 }; if(xl == l && xr == r) return val[o]; int mid = l + r >> 1;
	if(xr <= mid) return query(xl,xr,o << 1,l,mid); else if(xl > mid) return query(xl,xr,o << 1 | 1,mid + 1,r);
	else return query(xl,mid,o << 1,l,mid) + query(mid + 1,xr,o << 1 | 1,mid + 1,r);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in; build(); for(int i = 1;i <= n;i++) a[i] = in,id[i] = i;
	sort(id + 1,id + n + 1,[&](int x,int y) { return a[x] < a[y]; } );
	for(int i = 1,j = 1;i <= n;i = j) {
		while(j <= n && a[id[j]] == a[id[i]]) j++;
		for(int k = i;k < j;k++) {
			node ls = query(1,id[k]),rs = query(id[k] + 1,n);
			ans[id[k]] = max(ans[id[k]],(ls.rmx + rs.lmx) / 2);
		}
		for(int k = i;k < j;k++) upd(id[k],-1);
	}
	for(int i = 1,j = 1;i <= n;i = j) {
		while(j <= n && a[id[j]] == a[id[i]]) j++;
		for(int k = i;k < j;k++) upd(id[k],1);
		for(int k = i;k < j;k++) {
			node ls = query(1,id[k]),rs = query(id[k] + 1,n);
			ans[id[k]] = max(ans[id[k]],(ls.rmx + rs.lmx - 1) / 2);
		}
	}
	for(int i = 1;i <= n;i++) printf("%d%c",ans[i]," \n"[i == n]);
	return 0;
}
